<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        .header {
            width: 100%;
            height: 150px;
        }

        .nav>li {
            width: 100px;
            height: 50px;
            line-height: 50px;
            float: left;
            margin: 10px 50px;

            text-align: center;
        }

        .nav>li:hover {
            background-color: antiquewhite;
        }

        .sub_nav {
            width: 100px;
        }
    </style>
    <script src="/jquery.min.js"></script>

</head>

<body>
    <div class="header">
        <ul class="nav">
            <li>
                <a href="http://" target="_blank" rel="noopener noreferrer">导航1</a>
                <ul class="sub_nav">
                    <li>1<a href="http://" target="_blank" rel="noopener noreferrer">子菜单1</a></li>
                    <li>2<a href="http://" target="_blank" rel="noopener noreferrer">子菜单2</a></li>
                    <li>3<a href="http://" target="_blank" rel="noopener noreferrer">子菜单3</a></li>
                </ul>
            </li>
            <li>
                <a href="http://" target="_blank" rel="noopener noreferrer">导航2</a>
                <ul class="sub_nav">
                    <li>1<a href="http://" target="_blank" rel="noopener noreferrer">子菜单1</a></li>
                    <li>2<a href="http://" target="_blank" rel="noopener noreferrer">子菜单2</a></li>
                    <li>3<a href="http://" target="_blank" rel="noopener noreferrer">子菜单3</a></li>
                </ul>
            </li>
            <li>
                <a href="http://" target="_blank" rel="noopener noreferrer">导航3</a>
                <ul class="sub_nav">
                    <li>1<a href="http://" target="_blank" rel="noopener noreferrer">子菜单1</a></li>
                    <li>2<a href="http://" target="_blank" rel="noopener noreferrer">子菜单2</a></li>
                    <li>3<a href="http://" target="_blank" rel="noopener noreferrer">子菜单3</a></li>
                </ul>
            </li>
        </ul>
    </div>
    <script>
        $(function () {
            $('.nav>li,.sub_nav').mouseenter(e => {
                let n = e.target.tagName
                target = n == 'LI' ? $(e.target).children('ul') : $(e.target).siblings('ul')
                target.show()
            }).mouseleave(e => {
                let n = e.target.tagName
                target = n == 'LI' ? $(e.target).children('ul') : $(e.target).siblings('ul')
                target.hide()
            })
        })
    </script>
</body>

</html>